package org.jsoncrypto;


abstract class JcLibJwe {

  JcLibEnc mEnc;

  protected JcLibJwe(JcLibEnc enc, String algStr) throws JcBaseException {
    mEnc = enc;
    String alg = mEnc.mHeader.optString("alg", null);
    if (alg == null) {
      mEnc.setAlgStr(algStr);
    } else {
      if (!alg.equals(algStr)) {
        throw new JcBaseException("expected alg " + algStr);
      }
    }
  }

  protected JcLibJwe(String jwe) throws JcBaseException {
    mEnc = JcLibEnc.getInstance(jwe);
  }

}
